#
# Testing the Iterator@
#

require 'soul/iterator'
require 'test/unit'

class TestIterator < Test::Unit::TestCase

	def setup
		@string = "Hello World"
		@i = Soul::Iterator.new(@string)
		@e = Soul::Iterator.new(@string, @string.size-1)
	end

	def test_value
		assert(@i == "H")
		assert("H" == @i)
		assert(@i.next == "e")
	end

	def test_include?
		assert('H'.include? @i)
		assert('e'.include? @i.next)
		assert('o'.include? @i.next.succ.next)
	end

	def test_next
		(0 ... @string.size).each do |k|
			assert(@i == @string[k])
			@i.next
		end
	end

	def test_range
		i = 0
		(@i .. @e).each { |k| assert(@string[i] == k); i+=1 }
	end

end
